
//
//  YAYLliabilityViewController.m
//  yayi
//
//  Created by Veer on 16/3/22.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYAgreementViewController.h"

@interface YAYAgreementViewController ()

@property (nonatomic, weak) UIScrollView *sv;
@property (nonatomic, weak) UIWebView *webView;

@end

@implementation YAYAgreementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"雅同用户服务协议";
    
    [self setupNav];
    [self setupSubView];
}


- (void)setupNav
{

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"back_button"] forState:UIControlStateNormal];
    
    button.frame = (CGRect){{0, 0}, CGSizeMake(70, 30)};
    
    // 让按钮内部的所有内容左对齐
    button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //        [button sizeToFit];
    // 让按钮的内容往左边偏移10
    //        button.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    // 修改导航栏左边的item
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
}


- (void)setupSubView
{

    UIWebView *webView = [[UIWebView alloc] init];
    webView.frame = self.view.bounds;
    [self.view addSubview:webView];
    self.webView = webView;
    
    NSString * bundlePath = [[ NSBundle mainBundle] pathForResource: @ "html" ofType :@"bundle"];
    NSString *htmlPath= [bundlePath stringByAppendingPathComponent :@"agreement.html"];
    NSURL *url= [NSURL fileURLWithPath:htmlPath];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
}


- (void)back
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}


#pragma mark - 按钮相应方法


@end
